<!DOCTYPE html>
<html>
<head>
    <title>录入住院信息--中软高科-2015</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../../Css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="../../Css/bootstrap-responsive.css"/>
    <link rel="stylesheet" type="text/css" href="../../Css/style.css"/>
    <script type="text/javascript" src="../../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="../../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../../Js/ckform.js"></script>
    <script type="text/javascript" src="../../Js/common.js"></script>
    <script type="text/javascript" src="../../Js/ckeditor/ckeditor.js"></script>


    <style type="text/css">
        body {
            padding-bottom: 40px;
        }

        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
    <script type="text/javascript">
        $(function () {
            $('#backid').click(function () {
                window.location.href = "index.html";
            });

            $("input[name='hosrId']").bind('keypress', function (event) {
                if (event.keyCode == "13") {
                    queryHosregister();
                }
            })
        });

        // 保存住院信息
        function beHospitalSave() {
            // 不使用表单方式提交请求
            event.preventDefault();
            // 获取请求参数
            let hosrId = $("input[name='hosrId']").val();
            let behNursepeople = $("input[name='behNursepeople']").val();
            let behPatbed = $("input[name='behPatbed']").val();
            let behAntecedent = $("input[name='behAntecedent']").val();
            let behIllness = $("#behIllness").val();

            let behospital = {
                hosrId, behNursepeople, behPatbed, behAntecedent, behIllness
            }

            console.log(behospital)

            $.ajax({
                type: "POST",
                url: "/be-hosipital/save",
                dataType: "json",
                data: behospital,
                success: function (res) {
                    alert(res.msg);
                    if (res.code === 200) {
                        // 跳转至查询页
                        $(location).attr("href", "index.html");
                    }
                }
            });
        }

        // 查询挂号信息
        function queryHosregister() {
            let hosrId = $("input[name='hosrId']").val();
            $.ajax({
                url: `/registration/${hosrId}`,
                type: "GET",
                dataType: "json",
                success: function (res) {
                    if (res.code == 200) {
                        let reg = res.obj;
                        $("#hosrName").html(reg.hosrName);
                        $("#hosrIdcar").html(reg.hosrIdcar);
                        $("#hosrRegprice").html(reg.hosrRegprice);
                        $("#hosrMedical").html(reg.hosrMedical);

                        $("#hosrPhone").html(reg.hosrPhone);
                        $("#hosrSelfprice").html(reg.hosrSelfprice == '0' ? "自费" : "免费");
                        $("#hosrSex").html(reg.hosrSex == '0' ? "男" : "女");
                        $("#hosrAge").html(reg.hosrAge);
                        $("#hosrWork").html(reg.hosrWork);
                        $("#hosrLookdoctor").html(reg.hosrLookdoctor == '0' ? "初诊" : "复诊");
                        $("#dKeshi").html(reg.doctor.dKeshi);
                        $("#dName").html(reg.doctor.dName);
                        $("#hosrRemark").html(reg.hosrRemark);
                    }
                }
            })
        }

    </script>
</head>
<body>
<form action="index.html" method="post" class="definewidth m20">
    <table class="table table-bordered table-hover definewidth m10">
        <tr>
            <td width="10%" class="tableleft">病历号</td>
            <td><input type="text" name="hosrId" placeholder="输入病历号回车查询" value=""/></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">姓名</td>
            <td id="hosrName">黄飞鸿</td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">证件类型</td>
            <td>身份证</td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">证件号</td>
            <td id="hosrIdcar">42068325467876</td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">社保号</td>
            <td id="hosrMedical">423423432</td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">联系电话</td>
            <td id="hosrPhone">13126576456</td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">是否自费</td>
            <td id="hosrSelfprice"></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">性别</td>
            <td id="hosrSex"></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">年龄</td>
            <td id="hosrAge">33</td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">初复诊</td>
            <td id="hosrLookdoctor"></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">所挂科室</td>
            <td id="dKeshi"></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">指定医生</td>
            <td id="dName"></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">备注</td>
            <td id="hosrRemark">暂无 以上信息为输入病历号自动带出来的</td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">护理</td>
            <td><input type="text" name="behNursepeople" value=""/></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">床位号</td>
            <td><input type="text" name="behPatbed" value=""/></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">缴费押金</td>
            <td><input type="text" name="behAntecedent" value=""/></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">病情</td>
            <td><textarea id="behIllness"></textarea></td>
        </tr>
        <tr>
            <td colspan="2">
                <center>
                    <button onclick="beHospitalSave()" class="btn btn-primary" type="button">保存</button>
                    &nbsp;&nbsp;<button
                        type="button" class="btn btn-success" name="backid" id="backid">返回列表
                </button>
                </center>
            </td>
        </tr>
    </table>
</form>
</body>
</html>